//
//  StartAunt.swift
//  CopyAunt
//
//  Created by study on 2017/3/14.
//  Copyright © 2017年 WY. All rights reserved.
//

import UIKit

class StartAunt: UIView {

    /// 注册
    let registerBtn = UIButton()
    /// 登陆
    let loginBtn = UIButton()
    /// 去男生版
    let goManApp = UIButton()
    /// 背景图片
    let backgroundIcon:UIImageView = UIImageView()
    
   override init(frame: CGRect) {
    super.init(frame: frame)
    
        /// 创建 UI 界面
        setupView()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}

/// 创建 界面
extension StartAunt{
    /// 创建界面
    fileprivate func setupView(){
        /// 背景图片
        backgroundIcon.frame = CGRect(x: 0, y: 0, width: Int(frame.width), height: Int(frame.height))
        backgroundIcon.image = UIImage(named: "icon")
        self.addSubview(backgroundIcon)
        
        /// 注册
        registerBtn.setTitle("注册", for: .normal)
        registerBtn.setTitleColor(UIColor.black, for: .normal)
        registerBtn.backgroundColor =  UIColor.init(red: 255.0, green: 255.0, blue: 255.0, alpha: 0.5)
        registerBtn.layer.masksToBounds = true
        registerBtn.layer.cornerRadius = 24.0
        self.addSubview(registerBtn)
        
        /// 登陆
        loginBtn.setTitle("登陆", for: .normal)
        loginBtn.setTitleColor(UIColor.black, for: .normal)
        loginBtn.backgroundColor = UIColor.init(red: 255.0, green: 255.0, blue: 255.0, alpha: 0.5)
        loginBtn.layer.masksToBounds = true
        loginBtn.layer.cornerRadius = 24.0
        self.addSubview(loginBtn)
        
        /// 去男生版
        goManApp.setTitle("去男生版", for: .normal)
        goManApp.setTitleColor(UIColor.purple, for: .normal)
        self.addSubview(goManApp)

        setupViewFrame()
    }
    
    /// 创建界面的frame
    private func setupViewFrame(){
        /// 注册
        registerBtn.snp.makeConstraints { (make) in
            make.width.equalTo(150)
            make.height.equalTo(45)
            make.left.equalTo(self).offset(20)
            make.bottom.equalTo(self).offset(-100)
        }
        
        /// 登陆
        loginBtn.snp.makeConstraints { (make) in
            make.width.equalTo(registerBtn)
            make.height.equalTo(registerBtn)
            make.right.equalTo(self).offset(-20)
            make.bottom.equalTo(registerBtn)
        }
        
        /// 去男生版
        goManApp.snp.makeConstraints { (make) in
            make.width.equalTo(90)
            make.height.equalTo(20)
            make.right.equalTo(self).offset(0)
            make.bottom.equalTo(-38)
        }
    }
}
/*
/// 给UIButton 画 圆角
extension StartAunt{
    fileprivate func circleButton() ->(UIButton){
        
        /// 开启image绘制
        UIGraphicsBeginImageContextWithOptions(frame.size, false, 0.0)
        /// 获取上下文
        CGContextR
        return UIButton()
    }
}
 */
